<?php

namespace App\Providers;

use Illuminate\Http\Request;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Symfony\Component\HttpFoundation\Response;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\TestEvent' => [
            'App\Listener\TestListener',
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
        \Event::listen('laravels.received_request', function (Request $req, $app) {
//            $req->query->set('qq', 'hhxsv5');// 修改querystring
//            $req->request->set('ww', 'hhxsv5'); // 修改post body
        });
        \Event::listen('laravels.generated_response', function (Request $req, Response $rsp) {
//            $rsp->headers->set('header-key', 'hhxsv5');// 修改header
        });

        //
    }
}
